package exercise.day6;

import java.util.*;

/**
 * @author Dianzhi Han
 * @version 1.0
 * @description: TODO
 * @date 2022/10/30 22:33
 */
public class DD1_continuousMax {

    public static int GetMax(int a, int b) { //得到两个数的最大值
        return Math.max((a), (b));
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int size = sc.nextInt();
        int[] array = new int[size];
        for (int i = 0; i < size; i++) {
            array[i] = sc.nextInt();
        }
        int sum = array[0];
        int max = array[0];
        for (int i = 1; i < size; i++) {
            sum = GetMax(sum + array[i], array[i]); //状态方程
            if (sum >= max)
                max = sum;
        }
        System.out.println(max);
    }
}
